import { Body, Controller, Get, Param, Post } from 'routing-controllers';
import { ResumeEntity } from '../entity/resume.entity';
import { saveOnline, select } from '../service/resume.service';
import { message } from '../utils/result';
import { Code } from '../utils/code';

@Controller('/resume')
export class ResumeController {
  @Post('/save')
  async saveOnline(@Body() entity: ResumeEntity) {
    const index = await saveOnline(entity);
    if (index == 1) {
      return message(Code.SUCCESS, '保存成功');
    }
    return message(Code.ERROR_RESUME_ADD, '保存失败');
  }

  @Get('/list/:uid')
  async select(@Param('uid') uid: string) {
    const result = await select(uid);
    if (result) {
      return message(Code.SUCCESS, '获取成功', result);
    }
    return message(Code.ERROR_RESUME_SELECT, '获取失败');
  }
}
